package com.tg.app.activity.base;

import android.os.Bundle;
import androidx.annotation.Nullable;

import com.base.BaseActivity;
import com.tg.app.R;
import com.demo.view.LoadingDialog;
import com.tg.appcommon.android.TGToast;

public abstract class LoginBaseActivity extends BaseActivity {
    LoadingDialog mLoadingDialog;
    public  static  final  String   ACTION_USER_STATUS_LOGOUT ="Intent_action_user_status_logout";
    private static final int MIN_DELAY_TIME= 1000;  // 两次点击间隔不能少于1000ms
    private static long lastClickTime;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }


    protected abstract void initView();

    protected void showLoading(){
        if (mLoadingDialog==null){
            mLoadingDialog=new LoadingDialog(this);
            mLoadingDialog.setMsg(R.string.loading);
        }
        mLoadingDialog.show();
    }

    protected void showLoading(String message){
        if (mLoadingDialog==null){
            mLoadingDialog=new LoadingDialog(this);
            mLoadingDialog.setMsg(message);
        }
        mLoadingDialog.show();
    }

    protected void hideLoading(){
        if (mLoadingDialog!=null&&mLoadingDialog.isShowing()){
            mLoadingDialog.cancel();
        }
    }

    protected void showToast(final String msg){
        TGToast.showToast(msg);
    }

    protected void showToast(final int resId){
        TGToast.showToast(resId);
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();

        if(mLoadingDialog!=null&&mLoadingDialog.isShowing()){
            mLoadingDialog.cancel();
        }
        mLoadingDialog=null;
    }
}
